#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 1e5+10;
const int M = 1e9+7;

int n,m,r,p;
int a[N];

struct Edge
{
    int to, next;
} e[N << 1];

int head[N], idx = 1;

// 父节点，子树大小， 深度， 重点, 链头
int father[N], size[N], d[N], hson[N], top[N];

void add_edge(int u, int v)
{
    e[idx].to = v;
    e[idx].next = head[u];
    head[u] = idx++;
}
void clear_graph()
{
    memset(head, -1, sizeof(head));
    memset(e, 0, sizeof(e));
    idx = 1;
}

void dfs1(int u, int dep = 1) 
{
    int s = 1, m = 0;
    d[u] = dep;
    for  (int i = head[u]; ~i; i = e[i].next) {
        int v = e[i].to;
        if (!d[v]) {
            dfs1(v, dep+1);
            s += size[v];
            if (size[v] > m) {
                hson[u] = v;
                m = size[v];
            }
        }
    }
}

void dfs2(int u)
{
    for  (int i = head[u]; ~i; i = e[i].next) {
        int v = e[i].to;
        if (!top[v]) {
            top[v] = (v == hson[u]) ? top[u] : v;
            dfs2(v);
        }
    }
}

int main()
{
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0);
    cin >> n >> m >> r >> p;
    clear_graph();
    for (int i=1; i<=n; i++) cin >> a[i];
    for (int i=1; i<=n-1; i++) {
        int x,y;
        cin >> x >> y;
        add_edge(x, y);
        add_edge(y, x);
    }

    dfs1(1);
    dfs2(1);

    
    return 0;
}